package com.atguigu.oshi.common;


import lombok.Data;

@Data //对接前端的R，不用管泛型。对接后端远程调用需要泛型；
public class R {

    private Integer code;
    private String msg;
    private Object data; //json响应出去，要类型有啥用~~~; 序列化

    public R(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    //快速成功
    public static R ok() {
        return new R(200, "ok");
    }

    public static R ok(Object data) {
        return new R(200, "ok", data);
    }

    //快速失败
    public static R error() {
        return new R(500, "error");
    }

    public static R error(Object data) {
        return new R(500, "error", data);
    }

    public static R error(Integer code, String msg) {
        return new R(code, msg);
    }
}
